package com.web.dao;

import com.web.entity.DemandClass;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface DemandClassMapper {
    @Delete({
        "delete from APP_DEMAND_CLASS",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into APP_DEMAND_CLASS (theme, create_time, ",
        "modify_time)",
        "values (#{theme,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ",
        "#{modifyTime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(DemandClass record);

    int insertSelective(DemandClass record);

    @Select({
        "select",
        "id, theme, create_time, modify_time",
        "from APP_DEMAND_CLASS",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    DemandClass selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(DemandClass record);

    @Update({
        "update APP_DEMAND_CLASS",
        "set theme = #{theme,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "modify_time = #{modifyTime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(DemandClass record);

    List<DemandClass> allDemand();

}